//
//  KeChengPingLun.m
//  ZhiBoYuan
//
//  Created by apple on 2018/4/17.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "KeChengPingLun.h"
#import "CommentModel.h"
#import "CommentUserInfo.h"

@interface KeChengPingLun ()

@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UILabel *UserName;
@property (weak, nonatomic) IBOutlet UILabel *commentDetail;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *xingLabel;

@end

@implementation KeChengPingLun


- (void)setModel:(CommentModel *)model{
//    NSLog(@"%@",model.content);
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:model.user_info.avatar] placeholderImage:[UIImage imageNamed:@"图层18"]];
    self.headImage.layer.masksToBounds = YES;
    self.headImage.layer.cornerRadius = 25;
    self.UserName.text = model.user_info.name;
    self.commentDetail.text = model.content;
    self.timeLabel.text = model.create_time;
    
    
    NSMutableArray *nameArr =@[].mutableCopy;
    
    NSInteger xingNum = [model.star_num integerValue];
    
//    NSLog(@"%@",xingNum);
    
    self.xingLabel.text = @"";
    
    for (int i = 0; i<5; i++) {
        if ( i >= xingNum )
        {
            [nameArr addObject:@"五角星-1副本5"]; // 黄星星
        }
        else
        {
            [nameArr addObject:@"五角星-1"];  // 灰色星星
        }
    }
    
    NSMutableArray* buttons = [NSMutableArray arrayWithCapacity:5];
    CGRect btnRect = CGRectMake(0, -10, 20, 20);
    
    for (NSString* optionTitle in nameArr)
    {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:btnRect];
        btnRect.origin.x += 25;
        imageView.image = [UIImage imageNamed:optionTitle];
        [self.xingLabel addSubview:imageView];
        [buttons addObject:imageView];
    }
    
    
    
    
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
